home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gnats301.lha / gnats-3.01 / configure < prev    next >
Text File  |  1993-04-07  |  38KB  |  937 lines

  1. #!/bin/sh
  2.  
  3. ### WARNING: this file contains embedded tabs.  Do not run untabify on this file.
  4.  
  5. # Configuration script
  6. #   Copyright (C) 1988, 1990-1993 Free Software Foundation, Inc.
  7.  
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU General Public License for more details.
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. # Please email any bugs, comments, and/or additions to this file to:
  21. # configure@cygnus.com
  22.  
  23. # This file was written by K. Richard Pixley.
  24.  
  25. #
  26. # Shell script to create proper links to machine-dependent files in
  27. # preparation for compilation.
  28. #
  29. # If configure succeeds, it leaves its status in config.status.
  30. # If configure fails after disturbing the status quo, 
  31. #       config.status is removed.
  32. #
  33.  
  34. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0 $argv; kill $$)
  35.  
  36. remove=rm
  37. hard_link=ln
  38. symbolic_link='ln -s'
  39.  
  40. #for Test
  41. #remove="echo rm"
  42. #hard_link="echo ln"
  43. #symbolic_link="echo ln -s"
  44.  
  45. # clear some things potentially inherited from environment.
  46.  
  47. Makefile=Makefile
  48. Makefile_in=Makefile.in
  49. arguments=$*
  50. configdirs=
  51. exec_prefix=
  52. exec_prefixoption=
  53. fatal=
  54. floating_point=default
  55. gas=default
  56. host_alias=
  57. host_makefile_frag=
  58. moveifchange=
  59. next_host=
  60. next_prefix=
  61. next_site=
  62. next_srcdir=
  63. next_target=
  64. next_tmpdir=
  65. norecursion=
  66. package_makefile_frag=
  67. prefix=/usr/local
  68. progname=
  69. program_prefix=
  70. program_prefixoption=
  71. program_suffix=
  72. program_suffixoption=
  73. program_transform_name=
  74. program_transform_nameoption=
  75. redirect=">/dev/null"
  76. removing=
  77. site=
  78. site_makefile_frag=
  79. site_option=
  80. srcdir=
  81. srctrigger=
  82. subdirs=
  83. target_alias=
  84. target_makefile_frag=
  85. undefinedargs=
  86. version="$Revision: 1.151 $"
  87. x11=default
  88.  
  89. NO_EDIT="This file was generated automatically by configure.  Do not edit."
  90.  
  91. ## this is a little touchy and won't always work, but...
  92. ##
  93. ## if the argv[0] starts with a slash then it is an absolute name that can (and
  94. ## must) be used as is.
  95. ##
  96. ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
  97. ## path.  Since PATH might include "." we also add `pwd` to the end of PATH.
  98. ##
  99.  
  100. progname=$0
  101. # if PWD already has a value, it is probably wrong.
  102. if [ -n "$PWD" ]; then PWD=`pwd`; fi
  103.  
  104. case "${progname}" in
  105. /*) ;;
  106. */*) ;;
  107. *)
  108.         PATH=$PATH:${PWD=`pwd`} ; export PATH
  109.         ;;
  110. esac
  111.  
  112. for arg in $*;
  113. do
  114.         # handle things that might have args following as separate words
  115.         if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
  116.         elif [ -n "${next_exec_prefix}" ] ; then
  117.                 exec_prefix=${arg}
  118.                 exec_prefixoption="-exec_prefix=${exec_prefix}"
  119.                 next_exec_prefix=
  120.         elif [ -n "${next_site}" ] ; then site=${arg} ; site_option=-site=${site} ; next_site=
  121.         # remove any possible trailing slash from srcdir.  See note below.
  122.         elif [ -n "${next_srcdir}" ] ; then srcdir=`echo ${arg} | sed -e 's:/$::'` ; next_srcdir=
  123.         elif [ -n "${next_program_prefix}" ] ; then
  124.                 program_prefix=${arg}
  125.                 program_prefixoption="-program_prefix=${program_prefix}"
  126.                 next_program_prefix=
  127.         elif [ -n "${next_program_suffix}" ] ; then
  128.                 program_suffix=${arg}
  129.                 program_suffixoption="-program_suffix=${program_suffix}"
  130.                 next_program_suffix=
  131.         elif [ -n "${next_program_transform_name}" ] ; then
  132.                 # Double any backslashes or dollar signs in the argument
  133.         if [ -n "${arg}" ] ; then
  134.             program_transform_name="${program_transform_name} -e `echo ${arg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
  135.         fi
  136.                 program_transform_nameoption="${program_transform_nameoption} -program_transform_name='${arg}'"
  137.                 next_program_transform_name=
  138.         elif [ -n "${next_target}" ] ; then
  139.                 next_target=
  140.                 case "${target_alias}" in
  141.                 "")
  142.                         target_alias="${arg}"
  143.                         ;;
  144.                 *)
  145.                         echo '***' Can only configure for one target at a time.  1>&2
  146.                         fatal=yes
  147.                         ;;
  148.                 esac
  149.         elif [ -n "${next_tmpdir}" ] ; then
  150.                 next_tmpdir=
  151.                 tmpdiroption="--tmpdir=${arg}"
  152.                 TMPDIR=${arg}
  153.  
  154.         else
  155.                 case ${arg} in
  156.                 -exec_prefix=* | --exec_prefix=* | --exec_prefi=* | --exec_pref=* | --exec_pre=* | --exec_pr=* | --exec_p=* | --exec_=* | --exec=* | --exe=* | --ex=* | --e=* | -exec-prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* )
  157.                         exec_prefix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
  158.                         exec_prefixoption=${arg}
  159.                         ;;
  160.                 -exec_prefix | --exec_prefix | --exec_prefi | --exec_pref | --exec_pre | --exec_pr | --exec_p | --exec_ | --exec | --exe | --ex | --e | -exec-prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec-)
  161.                         next_exec_prefix=yes
  162.                         ;;
  163.                 -gas | --g*)
  164.                         gas=yes
  165.                         ;;
  166.                 -help | --he*)
  167.                         fatal=true
  168.                         ;;
  169.                 -host=* | --host=* | --hos=* | --ho=*)
  170.                         case "${host_alias}" in
  171.                         "")
  172.                                 host_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`"
  173.                                 ;;
  174.                         *)
  175.                                 echo '***' Can only configure for one host at a time.  1>&2
  176.                                 fatal=yes
  177.                                 ;;
  178.                         esac
  179.                         ;;
  180.                 -nfp | --nf*)
  181.                         floating_point=no
  182.                         ;;
  183.                 -norecursion | --no*)
  184.                         norecursion=true
  185.                         ;;
  186.                 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=*)
  187.                         prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
  188.                         prefixoption=${arg}
  189.                         ;;
  190.                 -prefix | --prefix | --prefi | --pref | --pre)
  191.                         next_prefix=yes
  192.                         ;;
  193.                 -rm | --rm) removing=${arg} ;;
  194.                 -program_prefix=* | --program_prefix=* | --program_prefi=* | --program_pref=* | --program_pre=* | --program_pr=* | --program_p=* | -program-prefix=* | --program-prefix=* | --program-prefi=* | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
  195.                         program_prefix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
  196.                         program_prefixoption=${arg}
  197.                         ;;
  198.                 -program_prefix | --program_prefix | --program_prefi | --program_pref | --program_pre | --program_pr | --program_p | -program-prefix | --program-prefix | --program-prefi | --program-pref | --program-pre | --program-pr | --program-p)
  199.                         next_program_prefix=yes
  200.                         ;;
  201.                 -program_suffix=* | --program_suffix=* | --program_suffi=* | --program_suff=* | --program_suf=* | --program_su=* | --program_s=* | -program-suffix=* | --program-suffix=* | --program-suffi=* | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
  202.                         program_suffix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
  203.                         program_suffixoption=${arg}
  204.                         ;;
  205.                 -program_suffix | --program_suffix | --program_suffi | --program_suff | --program_suf | --program_su | --program_s |-program-suffix | --program-suffix | --program-suffi | --program-suff | --program-suf | --program-su | --program-s)
  206.                         next_program_suffix=yes
  207.                         ;;
  208.                 -program_transform_name=* | --program_transform_name=* | --program_transform_nam=* | --program_transform_na=* | --program_transform_n=* | --program_transform_=* | --program_transform=* | --program_transfor=* | --program_transfo=* | --program_transf=* | --program_trans=* | --program_tran=* | --program_tra=* | --program_tr=* | --program_t=* | -program-transform-name=* | --program-transform-name=* | --program-transform-nam=* | --program-transform-na=* | --program-transform-n=* | --program-transform-=* | --program-transform=* | --program-transfor=* | --program-transfo=* | --program-transf=* | --program-trans=* | --program-tran=* | --program-tra=* | --program-tr=* | --program-t=*)
  209.             arg=`echo ${arg} | sed -e 's/^[-a-z_]*=//'`
  210.                         # Double any \ or $ in the argument
  211.             if [ -n "${arg}" ] ; then
  212.                             program_transform_name="${program_transform_name} -e `echo ${arg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
  213.             fi
  214.                         program_transform_nameoption="${program_transform_nameoption} -program_transform_name='${arg}'"
  215.                         ;;
  216.                 -program_transform_name | --program_transform_name | --program_transform_nam | --program_transform_na | --program_transform_n | --program_transform_ | --program_transform | --program_transfor | --program_transfo | --program_transf | --program_trans | --program_tran | --program_tra | --program_tr | --program_t | -program-transform-name | --program-transform-name | --program-transform-nam | --program-transform-na | --program-transform-n | --program-transform- | --program-transform | --program-transfor | --program-transfo | --program-transf | --program-trans | --program-tran | --program-tra | --program-tr | --program-t)
  217.                         next_program_transform_name=yes
  218.                         ;;
  219.                 -site=* | --site=* | --sit=* | --si=*)
  220.                         site_option=${arg}
  221.                         site=`echo ${arg} | sed 's/^[-a-z]*=//'`
  222.                         ;;
  223.                 -site | --site | --sit)
  224.                         next_site=yes
  225.                         ;;
  226.                 # remove trailing slashes.  Otherwise, when the file name gets
  227.                 # bolted into an object file as debug info, it has two slashes in
  228.                 # it.  Ordinarily this is ok, but emacs takes double slash to
  229.                 # mean "forget the first part".
  230.                 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
  231.                         srcdir=`echo ${arg} | sed 's/^[-a-z]*=//' | sed -e 's:/$::'`
  232.                         ;;
  233.                 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
  234.                         next_srcdir=yes
  235.                         ;;
  236.                 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
  237.                         case "${target_alias}" in
  238.                         "") target_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`" ;;
  239.                         *)
  240.                                 echo '***' Can only configure for one target at a time.  1>&2
  241.                                 fatal=yes
  242.                                 ;;
  243.                         esac
  244.                         ;;
  245.                 -target | --target | --targe | --targ | --tar | --ta)
  246.                         next_target=yes
  247.                         ;;
  248.                 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
  249.                         tmpdiroption=${arg}
  250.                         TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
  251.                         ;;
  252.                 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
  253.                         next_tmpdir=yes
  254.                         ;;
  255.                 -v | -verbose | --v)
  256.                         redirect=
  257.                         verbose=-v
  258.                         ;;
  259.                 -version | -V | --version | --V)
  260.                         echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
  261.                         exit 0
  262.                         ;;
  263.                 -with*=* | --with*=*)
  264.                         withopt=`echo ${arg} | sed 's:^-*\(with[^=]*\)=.*$:\1:;s/-/_/g'`
  265.                         withval=`echo ${arg} | sed 's:^-*with[^=]*=\(.*\)$:\1:'`
  266.                         eval $withopt="$withval"
  267.                         withoptions="$withoptions $arg"
  268.                         ;;
  269.                 -without* | --without*)
  270.                         withopt=`echo ${arg} | sed 's:^-*without:with:;s/-/_/g'`        
  271.                         eval $withopt=no
  272.                         withoutoptions="$withoutoptions $arg"
  273.                         ;;
  274.                 -with* | --with*)
  275.                         withopt=`echo ${arg} | sed 's:^-*with:with:;s/-/_/g'`
  276.                         eval $withopt=yes
  277.                         withoptions="$withoptions $arg"
  278.                         ;;
  279.                 -x | --x) ;;
  280.                 -* | --*)
  281.                         (echo ;
  282.                         echo "Unrecognized option: \"${arg}\"". ;
  283.                         echo) 1>&2
  284.                         fatal=true
  285.                         ;;
  286.                 *)
  287.                         case "${undefs}" in
  288.                         "")
  289.                                 undefs="${arg}"
  290.                                 ;;
  291.                         *)
  292.                                 echo '***' Can only configure for one host and one target at a time.  1>&2
  293.                                 fatal=yes
  294.                                 ;;
  295.                         esac
  296.                         ;;
  297.                 esac
  298.         fi
  299. done
  300.  
  301. # process host and target
  302. case "${fatal}" in
  303. "")
  304. #       # Complain if an arg is missing
  305. #       if [ -z "${host_alias}" ] ; then
  306. #               (echo ;
  307. #               echo "configure: No HOST specified." ;
  308. #               echo) 1>&2
  309. #               fatal=true
  310. #       fi
  311.  
  312. ### This is a bit twisted.
  313. ### * if all three are specified, this is an error.
  314. ### * if we have neither hosts, nor unadorned args, this is an error.
  315. ### * if no hosts are specified, then the unadorned args are hosts, but if
  316. ### there were none, this is an error.
  317. ### * if no targets are specified, then the unadorned args are targets, but if
  318. ### there were no unadorned args, then the hosts are also targets.
  319.  
  320.         if [ -n "${host_alias}" -a -n "${target_alias}" -a -n "${undefs}" ] ; then
  321.                 echo '***' Can only configure for one host and one target at a time.  1>&2
  322.                 fatal=yes
  323.         elif [ -z "${host_alias}" -a -z "${undefs}" ] ; then
  324.                 echo '- You did not tell me what kind of host system you want to configure.
  325. - I will attempt to guess the kind of system this is.' 1>&2
  326.                 guesssys=`echo ${progname} | sed 's/configure$/config.guess/'`
  327.                 if tmp_alias=`${guesssys}` ; then
  328.                         echo "- Looks like this is a ${tmp_alias}" 1>&2
  329.                         host_alias=${tmp_alias}
  330.             case "${target_alias}" in
  331.             "") target_alias=${tmp_alias} ;;
  332.             *) ;;
  333.             esac
  334.             arguments="--host=${host_alias} ${arguments}"
  335.                 else
  336.                         echo '- Failed to guess the system type.  You need to tell me.' 1>&2
  337.                         fatal=yes
  338.                 fi
  339.         else
  340.                 case "${host_alias}" in
  341.                 "") host_alias=${undefs} ;;
  342.                 *) ;;
  343.                 esac
  344.  
  345.                 case "${target_alias}" in
  346.                 "")
  347.                         case "${undefs}" in
  348.                         "")     target_alias=${host_alias} ;;
  349.                         *)      target_alias=${undefs} ;;
  350.                         esac
  351.                         ;;
  352.                 *) ;;
  353.                 esac
  354.         fi
  355.         ;;
  356. *) ;;
  357. esac
  358.  
  359. if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
  360.         (echo "Usage: configure HOST" ;
  361.         echo ;
  362.         echo "Options: [defaults in brackets]" ;
  363.         echo " -prefix=MYDIR            configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
  364.         echo " -exec-prefix=MYDIR       configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
  365.         echo " -help                    print this message. [normal config]" ;
  366.         echo " -norecursion             configure this directory only. [recurse]" ;
  367.         echo " -program-prefix=FOO      install programs with FOO prepended to their names. [ \"\" ]" ;
  368.         echo " -program-suffix=FOO      install programs with FOO appended to their names. [ \"\" ]" ;
  369.         echo " -program-transform-name=FOO      install programs with names transformed by sed pattern FOO. [ \"\" ]" ;
  370.         echo " -site=SITE               configure with site specific makefile for SITE" ;
  371.         echo " -srcdir=DIR              find the sources in DIR. [\".\" or \"..\"]" ;
  372.         echo " -target=TARGET           configure for TARGET.  [TARGET = HOST]" ;
  373.         echo " -tmpdir=TMPDIR           create temporary files in TMPDIR.  [ TMPDIR = \"/tmp\" ]" ;
  374.         echo " -nfp                     configure the compilers default to soft floating point. [hard float]" ;
  375.         echo " -with-FOO, -with-FOO=BAR specify that FOO is available"
  376.         echo " -without-FOO             specify that FOO is NOT available"
  377.         echo ;
  378.         echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
  379.         echo ;
  380.         ) 1>&2
  381.         if [ -r config.status ] ; then
  382.                 cat config.status
  383.         fi
  384.  
  385.         exit 1
  386. fi
  387.  
  388. configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
  389. moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
  390.  
  391. # this is a hack.  sun4 must always be a valid host alias or this will fail.
  392. if ${configsub} sun4 >/dev/null 2>&1 ; then
  393.         true
  394. else
  395.         echo '***' cannot find config.sub.  1>&2
  396.         exit 1
  397. fi
  398.  
  399. touch config.junk
  400. if ${moveifchange} config.junk config.trash ; then
  401.         true
  402. else
  403.         echo '***' cannot find move-if-change.  1>&2
  404.         exit 1
  405. fi
  406. rm -f config.junk config.trash
  407.  
  408. case "${srcdir}" in
  409. "")
  410.         if [ -r configure.in ] ; then
  411.                 srcdir=.
  412.         else
  413.                 if [ -r ${progname}.in ] ; then
  414.                         srcdir=`echo ${progname} | sed 's:/configure$::'`
  415.                 else
  416.                         echo '***' "Can't find configure.in.  Try using -srcdir=some_dir"  1>&2
  417.                         exit 1
  418.                 fi
  419.         fi
  420.         ;;
  421. *) ;;
  422. esac
  423.  
  424. ### warn about some conflicting configurations.
  425.  
  426. case "${srcdir}" in
  427. ".") ;;
  428. *)
  429.         if [ -f ${srcdir}/config.status ] ; then
  430.                 echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
  431.                 exit 1
  432.         fi
  433. esac
  434.  
  435. # default exec_prefix
  436. case "${exec_prefix}" in
  437. "") exec_prefix="\$(prefix)" ;;
  438. *) ;;
  439. esac
  440.  
  441. ### break up ${srcdir}/configure.in.
  442. case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
  443. "")
  444.         echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
  445.         exit 1
  446.         ;;
  447. *) ;;
  448. esac
  449.  
  450. case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
  451. "")
  452.         echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
  453.         exit 1
  454.         ;;
  455. *) ;;
  456. esac
  457.  
  458. case "${TMPDIR}" in
  459. "") TMPDIR=/tmp ; export TMPDIR ;;
  460. *) ;;
  461. esac
  462.  
  463. # keep this filename short for &%*%$*# 14 char file names
  464. tmpfile=${TMPDIR}/cONf$$
  465. trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
  466.  
  467. # split ${srcdir}/configure.in into common, per-host, per-target,
  468. # and post-target parts.  Post-target is optional.
  469. sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
  470. sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
  471. if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
  472.   sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
  473.   sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
  474. else
  475.   sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
  476.   echo >${tmpfile}.pos
  477. fi
  478.  
  479. ### do common part of configure.in
  480.  
  481. . ${tmpfile}.com
  482.  
  483. # some sanity checks on configure.in
  484. case "${srctrigger}" in
  485. "")
  486.         echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in.  1>&2
  487.         exit 1
  488.         ;;
  489. *) ;;
  490. esac
  491.  
  492. result=`${configsub} ${host_alias}`
  493. host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
  494. host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
  495. host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
  496. host=${host_cpu}-${host_vendor}-${host_os}
  497.  
  498. . ${tmpfile}.hst
  499.  
  500. result=`${configsub} ${target_alias}`
  501. target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
  502. target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
  503. target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
  504. target=${target_cpu}-${target_vendor}-${target_os}
  505.  
  506. . ${tmpfile}.tgt
  507.  
  508. # Find the source files, if location was not specified.
  509. case "${srcdir}" in
  510. "")
  511.         srcdirdefaulted=1
  512.         srcdir=.
  513.         if [ ! -r ${srctrigger} ] ; then
  514.                 srcdir=..
  515.         fi
  516.         ;;
  517. *) ;;
  518. esac
  519.  
  520. if [ ! -r ${srcdir}/${srctrigger} ] ; then
  521.         case "${srcdirdefaulted}" in
  522.         "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
  523.         *)  echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
  524.         esac
  525.  
  526.         echo '***' \(At least ${srctrigger} is missing.\) 1>&2
  527.         exit 1
  528. fi
  529.  
  530. tooldir="\$(libdir)/${target_alias}"
  531.  
  532. if [ "${host_alias}" != "${target_alias}" ] ; then
  533.     if [ "${program_prefixoption}" = "" ] ; then
  534.         if [ "${program_suffixoption}" = "" ] ; then 
  535.             if [ "${program_transform_nameoption}" = "" ] ; then
  536.                 program_prefix=${target_alias}- ;
  537.             fi
  538.         fi
  539.     fi
  540. fi
  541.  
  542. # Merge program_prefix and program_suffix onto program_transform_name
  543. # Use a double $ so that make ignores it
  544. if [ "${program_suffix}" != "" ] ; then
  545.     program_transform_name="-e s/\$\$/${program_suffix}/ ${program_transform_name}"
  546. fi
  547.  
  548. if [ "${program_prefix}" != "" ] ; then
  549.     program_transform_name="-e s/^/${program_prefix}/ ${program_transform_name}"
  550. fi
  551.  
  552. for subdir in . ${subdirs} ; do
  553.  
  554.     # ${subdir} is relative path from . to the directory we're currently
  555.     # configuring.
  556.     # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
  557.     invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
  558.  
  559.     ### figure out what to do with srcdir
  560.     case "${srcdir}" in
  561.         ".")  # no -srcdir option.  We're building in place.
  562.                 makesrcdir=. ;;
  563.         /*) # absolute path
  564.                 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
  565.                 ;;
  566.         *) # otherwise relative
  567.                 case "${subdir}" in
  568.                 .) makesrcdir=${srcdir} ;;
  569.                 *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
  570.                 esac
  571.                 ;;
  572.     esac
  573.  
  574.     if [ "${subdir}/" != "./" ] ; then
  575.         Makefile=${subdir}/Makefile
  576.     fi
  577.  
  578.     if [ ! -d ${subdir} ] ; then
  579.         if mkdir ${subdir} ; then
  580.                 true
  581.         else
  582.                 echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2
  583.                 exit 1
  584.         fi
  585.     fi
  586.  
  587.     case "${removing}" in
  588.     "")
  589.         case "${subdir}" in
  590.         .) ;;
  591.         *) eval echo Building in ${subdir} ${redirect} ;;
  592.         esac
  593.  
  594.         # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
  595.         # Set up the list of links to be made.
  596.         # ${links} is the list of link names, and ${files} is the list of names to link to.
  597.  
  598.         # Make the links.
  599.         configlinks="${links}"
  600.         if [ -r ${subdir}/config.status ] ; then
  601.                 mv -f ${subdir}/config.status ${subdir}/config.back
  602.         fi
  603.         while [ -n "${files}" ] ; do
  604.                 # set file to car of files, files to cdr of files
  605.                 set ${files}; file=$1; shift; files=$*
  606.                 set ${links}; link=$1; shift; links=$*
  607.  
  608.                 if [ ! -r ${srcdir}/${file} ] ; then
  609.                         echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
  610.                         echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
  611.                         exit 1
  612.                 fi
  613.  
  614.                 ${remove} -f ${link}
  615.                 # Make a symlink if possible, otherwise try a hard link
  616.                 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
  617.  
  618.                 if [ ! -r ${link} ] ; then
  619.                         echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
  620.                         exit 1
  621.                 fi
  622.  
  623.                 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
  624.         done
  625.  
  626.         # Create a .gdbinit file which runs the one in srcdir
  627.         # and tells GDB to look there for source files.
  628.  
  629.         if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
  630.                 case ${srcdir} in
  631.                 .) ;;
  632.                 *) cat > ${subdir}/.gdbinit <<EOF
  633. # ${NO_EDIT}
  634. dir .
  635. dir ${makesrcdir}
  636. source ${makesrcdir}/.gdbinit
  637. EOF
  638.                         ;;
  639.                 esac
  640.         fi
  641.  
  642.         # Install a makefile, and make it set VPATH
  643.         # if necessary so that the sources are found.
  644.         # Also change its value of srcdir.
  645.         # NOTE: Makefile generation constitutes the majority of the time in configure.  Hence, this section has
  646.         # been somewhat optimized and is perhaps a bit twisty.
  647.  
  648.         # code is order so as to try to sed the smallest input files we know.
  649.  
  650.         # the four makefile fragments MUST end up in the resulting Makefile in this order: 
  651.         # package, target, host, and site.  so do these separately because I don't trust the
  652.         #  order of sed -e expressions.
  653.  
  654.         if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
  655.  
  656.             # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
  657.             rm -f ${subdir}/Makefile.tem
  658.               case "${site}" in
  659.               "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
  660.               *)
  661.                       site_makefile_frag=${srcdir}/config/ms-${site}
  662.  
  663.                       if [ -f ${site_makefile_frag} ] ; then
  664.                               sed -e "/^####/  r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
  665.                                       > ${subdir}/Makefile.tem
  666.                       else
  667.                               cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
  668.                               site_makefile_frag=
  669.                       fi
  670.                       ;;
  671.             esac
  672.             # working copy now in ${subdir}/Makefile.tem
  673.  
  674.             # Conditionalize the makefile for this host.
  675.             rm -f ${Makefile}
  676.             case "${host_makefile_frag}" in
  677.               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
  678.               *)
  679.                       if [ ! -f ${host_makefile_frag} ] ; then
  680.                               host_makefile_frag=${srcdir}/${host_makefile_frag}
  681.                       fi
  682.                       if [ -f ${host_makefile_frag} ] ; then
  683.                               sed -e "/^####/  r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
  684.                       else
  685.                               echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
  686.                               echo '***' is missing in ${PWD=`pwd`}. 1>&2
  687.                               mv ${subdir}/Makefile.tem ${Makefile}
  688.                       fi
  689.             esac
  690.             # working copy now in ${Makefile}
  691.  
  692.             # Conditionalize the makefile for this target.
  693.             rm -f ${subdir}/Makefile.tem
  694.             case "${target_makefile_frag}" in
  695.               "") mv ${Makefile} ${subdir}/Makefile.tem ;;
  696.               *)
  697.                       if [ ! -f ${target_makefile_frag} ] ; then
  698.                               target_makefile_frag=${srcdir}/${target_makefile_frag}
  699.                       fi
  700.                       if [ -f ${target_makefile_frag} ] ; then
  701.                               sed -e "/^####/  r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
  702.                       else
  703.                               mv ${Makefile} ${subdir}/Makefile.tem
  704.                               target_makefile_frag=
  705.                       fi
  706.                       ;;
  707.             esac
  708.             # real copy now in ${subdir}/Makefile.tem
  709.  
  710.             # Conditionalize the makefile for this package.
  711.             rm -f ${Makefile}
  712.             case "${package_makefile_frag}" in
  713.               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
  714.               *)
  715.                       if [ ! -f ${package_makefile_frag} ] ; then
  716.                               package_makefile_frag=${srcdir}/${package_makefile_frag}
  717.                       fi
  718.                       if [ -f ${package_makefile_frag} ] ; then
  719.                               sed -e "/^####/  r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
  720.                       else
  721.                               echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
  722.                               echo '***' is missing in ${PWD=`pwd`}. 1>&2
  723.                               mv ${subdir}/Makefile.tem ${Makefile}
  724.                       fi
  725.             esac
  726.             # working copy now in ${Makefile}
  727.  
  728.             mv ${Makefile} ${subdir}/Makefile.tem
  729.  
  730.             # real copy now in ${subdir}/Makefile.tem
  731.  
  732.             # prepend warning about editting, and a bunch of variables.
  733.             rm -f ${Makefile}
  734.             cat > ${Makefile} <<EOF
  735. # ${NO_EDIT}
  736. VPATH = ${makesrcdir}
  737. links = ${configlinks}
  738. host_alias = ${host_alias}
  739. host_cpu = ${host_cpu}
  740. host_vendor = ${host_vendor}
  741. host_os = ${host_os}
  742. host_canonical = ${host_cpu}-${host_vendor}-${host_os}
  743. target_alias = ${target_alias}
  744. target_cpu = ${target_cpu}
  745. target_vendor = ${target_vendor}
  746. target_os = ${target_os}
  747. target_canonical = ${target_cpu}-${target_vendor}-${target_os}
  748. EOF
  749.             case "${package_makefile_frag}" in
  750.               "") ;;
  751.               /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
  752.               *)  echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
  753.             esac
  754.  
  755.             case "${target_makefile_frag}" in
  756.               "") ;;
  757.               /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
  758.               *)  echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
  759.             esac
  760.  
  761.             case "${host_makefile_frag}" in
  762.               "") ;;
  763.               /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
  764.               *)  echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
  765.             esac
  766.  
  767.             if [ "${site_makefile_frag}" != "" ] ; then
  768.                 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
  769.             fi 
  770.  
  771.             # fixme: this shouldn't be in configure.
  772.             # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
  773.             case "${host_alias}" in
  774.               "${target_alias}")
  775.                       echo "ALL=all.internal" >> ${Makefile}
  776.                       ;;
  777.               *)
  778.                       echo "CROSS=-DCROSS_COMPILE" >> ${Makefile}
  779.                       echo "ALL=all.cross" >> ${Makefile}
  780.                       ;;
  781.             esac
  782.  
  783.             # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
  784.             # remove any form feeds.
  785.             if [ -z "${subdirs}" ]; then
  786.                 rm -f ${subdir}/Makefile.tem2
  787.                 sed -e "s:^SUBDIRS[     ]*=.*$:SUBDIRS = ${configdirs}:" \
  788.                     -e "s:^NONSUBDIRS[     ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
  789.                     ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
  790.                 rm -f ${subdir}/Makefile.tem
  791.                 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
  792.             fi
  793.             sed -e "s:^prefix[     ]*=.*$:prefix = ${prefix}:" \
  794.                     -e "s:^exec_prefix[     ]*=.*$:exec_prefix = ${exec_prefix}:" \
  795.                     -e "s:^srcdir[     ]*=.*$:srcdir = ${makesrcdir}:" \
  796.                     -e "s/ //" \
  797.                     -e "s:^program_prefix[     ]*=.*$:program_prefix = ${program_prefix}:" \
  798.                     -e "s:^program_suffix[     ]*=.*$:program_suffix = ${program_suffix}:" \
  799.                     -e "s:^program_transform_name[     ]*=.*$:program_transform_name = ${program_transform_name}:" \
  800.                     -e "s:^tooldir[     ]*=.*$:tooldir = ${tooldir}:" \
  801.                     ${subdir}/Makefile.tem >> ${Makefile}
  802.             # final copy now in ${Makefile}
  803.  
  804.         else
  805.            echo "No Makefile.in found in ${srcdir}, unable to configure" 1>&2
  806.         fi
  807.  
  808.         rm -f ${subdir}/Makefile.tem
  809.  
  810.         case "${host_makefile_frag}" in
  811.         "") using= ;;
  812.         *) using="and \"${host_makefile_frag}\"" ;;
  813.         esac
  814.  
  815.         case "${target_makefile_frag}" in
  816.         "") ;;
  817.         *) using="${using} and \"${target_makefile_frag}\"" ;;
  818.         esac
  819.  
  820.         case "${site_makefile_frag}" in
  821.         "") ;;
  822.         *) using="${using} and \"${site_makefile_frag}\"" ;;
  823.         esac
  824.  
  825.         newusing=`echo "${using}" | sed 's/and/using/'`
  826.         using=${newusing}
  827.         echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
  828.  
  829.         . ${tmpfile}.pos
  830.  
  831.         # describe the chosen configuration in config.status.
  832.         # Make that file a shellscript which will reestablish
  833.         # the same configuration.  Used in Makefiles to rebuild
  834.         # Makefiles.
  835.  
  836.         case "${norecursion}" in
  837.         "") arguments="${arguments} -norecursion" ;;
  838.         *) ;;
  839.         esac
  840.  
  841.         if [ ${subdir} = . ] ; then
  842.             echo "#!/bin/sh
  843. # ${NO_EDIT}
  844. # This directory was configured as follows:
  845. ${progname}" ${arguments}  "
  846. # ${using}" > ${subdir}/config.new
  847.         else
  848.             echo "#!/bin/sh
  849. # ${NO_EDIT}
  850. # This directory was configured as follows:
  851. cd ${invsubdir}
  852. ${progname}" ${arguments}  "
  853. # ${using}" > ${subdir}/config.new
  854.         fi
  855.         chmod a+x ${subdir}/config.new
  856.         if [ -r ${subdir}/config.back ] ; then
  857.                 mv -f ${subdir}/config.back ${subdir}/config.status
  858.         fi
  859.         ${moveifchange} ${subdir}/config.new ${subdir}/config.status
  860.         ;;
  861.  
  862.     *)  rm -f ${Makefile} ${subdir}/config.status ${links} ;;
  863.     esac
  864. done
  865.  
  866. # If there are subdirectories, then recur. 
  867. if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then 
  868.         for configdir in ${configdirs} ; do
  869.  
  870.                 if [ -d ${srcdir}/${configdir} ] ; then
  871.                         eval echo Configuring ${configdir}... ${redirect}
  872.                         case "${srcdir}" in
  873.                         ".") ;;
  874.                         *)
  875.                                 if [ ! -d ./${configdir} ] ; then
  876.                                         if mkdir ./${configdir} ; then
  877.                                                 true
  878.                                         else
  879.                                                 echo '***' "${progname}: could not make ${PWD=`pwd`}/${configdir}" 1>&2
  880.                                                 exit 1
  881.                                         fi
  882.                                 fi
  883.                                 ;;
  884.                         esac
  885.  
  886.                         POPDIR=${PWD=`pwd`}
  887.                         cd ${configdir} 
  888.  
  889. ### figure out what to do with srcdir
  890.                         case "${srcdir}" in
  891.                         ".") newsrcdir=${srcdir} ;; # no -srcdir option.  We're building in place.
  892.                         /*) # absolute path
  893.                                 newsrcdir=${srcdir}/${configdir}
  894.                                 srcdiroption="-srcdir=${newsrcdir}"
  895.                                 ;;
  896.                         *) # otherwise relative
  897.                                 newsrcdir=../${srcdir}/${configdir}
  898.                                 srcdiroption="-srcdir=${newsrcdir}"
  899.                                 ;;
  900.                         esac
  901.  
  902. ### check for guested configure, otherwise fix possibly relative progname
  903.                         if [ -f ${newsrcdir}/configure ] ; then
  904.                                 recprog=${newsrcdir}/configure
  905.                         else
  906.                                 case "${progname}" in
  907.                                 /*)     recprog=${progname} ;;
  908.                                 *)      recprog=../${progname} ;;
  909.                                 esac
  910.                         fi
  911.  
  912. ### The recursion line is here.
  913.                         if eval ${recprog} ${verbose} --host=${host_alias} --target=${target_alias} \
  914.                                 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
  915.                                 ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${removing} ${redirect} ; then
  916.                                 true
  917.                         else
  918.                                 exit 1
  919.                         fi
  920.  
  921.                         cd ${POPDIR}
  922.                 fi
  923.         done
  924. fi
  925.  
  926. exit 0
  927.  
  928. #
  929. # Local Variables:
  930. # fill-column: 131
  931. # End:
  932. #
  933.  
  934. # end of configure
  935.